/* 
 * File:   test_stringHelper.h
 * Author: ferranferri
 *
 * Created on May 6, 2013, 6:44 PM
 */

#ifndef TEST_STRINGHELPER_H
#define	TEST_STRINGHELPER_H

#include <gtest/gtest.h>
#include "core/core_utils.h"

class StringHelper_TestFixture: public ::testing::Test
{
public:
	virtual void SetUp()
        {
            
	}
};

TEST_F(StringHelper_TestFixture, StringHelper_getSubstr_if_init_not_found_return_empty)
{
    ASSERT_EQ(z3d::utils::StringHelper::getSubstr("nnnnn","zzzzz","aaaaazzzzzzbbbbb"), "");
}

TEST_F(StringHelper_TestFixture, StringHelper_getSubstr_if_end_not_found_return_empty)
{
    ASSERT_EQ(z3d::utils::StringHelper::getSubstr("nnnnn","zzz1111111","aaaaazzzzzzbbbbb"), "");
}

TEST_F(StringHelper_TestFixture, StringHelper_getSubstr_returns_the_string_between_markers)
{
    ASSERT_EQ(z3d::utils::StringHelper::getSubstr("www.","/search","http://www.google.com/search?=gsdsfgsdfg%20rwerwe"), "google.com");
    ASSERT_EQ(z3d::utils::StringHelper::getSubstr("desde aqui "," hasta aqui","quiero buscar que letra hay desde aqui arriba hasta aqui"), "arriba");
}

TEST_F(StringHelper_TestFixture, StringHelper_getSubstr_empty_init_represents_start_of_the_string)
{
    ASSERT_EQ(z3d::utils::StringHelper::getSubstr("","/search","http://www.google.com/search?=gsdsfgsdfg%20rwerwe"), "http://www.google.com");
}

TEST_F(StringHelper_TestFixture, StringHelper_getSubstr_empty_end_represents_end_of_the_string)
{
    ASSERT_EQ(z3d::utils::StringHelper::getSubstr("www.","","http://www.google.com/search"), "google.com/search");
}
TEST_F(StringHelper_TestFixture, StringHelper_getSubstr_close_limits_means_empty_result)
{
    ASSERT_EQ(z3d::utils::StringHelper::getSubstr("www.","://www.google.com/search","http://www.google.com/search"), "");
}

#endif	/* TEST_STRINGHELPER_H */

